import React, { useState, forwardRef, useImperativeHandle } from 'react';
import UploadFile from '@/renderer/components/UploadAvatar';
import TextField from '@mui/material/TextField';

function AddProject(props, ref) {
  const [submit, setsubmit] = useState({
    logo_url: null,
    project_name: '',
    project_address: '',
  });

  useImperativeHandle(ref, () => ({
    submit,
  }));

  return (
    <div>
      <UploadFile
        value={submit.logo_url}
        onChange={(val) => {
          setsubmit((s) => ({
            ...s,
            logo_url: val,
          }));
        }}
      />
      <TextField
        fullWidth
        id="outlined-basic"
        label="项目名称"
        variant="outlined"
        value={submit.project_name}
        style={{ margin: '12px 0 18px 0' }}
        onChange={(e) => {
          setsubmit((s) => ({
            ...s,
            project_name: e.target.value,
          }));
        }}
      />
      <TextField
        fullWidth
        id="outlined-basic"
        label="项目地址"
        variant="outlined"
        value={submit.project_address}
        onChange={(e) => {
          setsubmit((s) => ({
            ...s,
            project_address: e.target.value,
          }));
        }}
      />
    </div>
  );
}

export default forwardRef(AddProject);
